package day0613;

import java.util.Arrays;
import java.util.Random;

public class Test1 {
    public static void main(String[] args) {
        String[]  names={"张三","李四","王五","赵六","孙七"};
        Random  rd=new Random();
        //用循环操作数组中的每一个，具体如下：
        //先用names[0]和names[随机数]
        //先用names[1]和names[随机数]
        //先用names[2]和names[随机数]
        //先用names[3]和names[随机数]
        //先用names[4]和names[随机数]
        for(int i=0;i<names.length; i++){
            int num=rd.nextInt(5); //[0,5)
            String t=names[i];
            names[i]=names[num];
            names[num]=t;
        }
        System.out.println(Arrays.toString(names));

    }
}
